//
//  HeadView.m
//  MusicNews
//
//  Created by lanou3g on 15/10/13.
//  Copyright © 2015年 LC.J. All rights reserved.
//

#import "HeadView.h"

@implementation HeadView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSCrollView];
    }
    return self;
}
#pragma mark - 添加轮播图的ScrollView
- (void)addSCrollView
{
    
    _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, 190)];
    _scrollView.contentSize = CGSizeMake(self.bounds.size.width * 5, 0);
    _iamge1 = [[UIImageView alloc] initWithFrame:CGRectMake(self.bounds.size.width * 1, 0, self.bounds.size.width, 190)];
    _iamge2 = [[UIImageView alloc] initWithFrame:CGRectMake(self.bounds.size.width * 2, 0, self.bounds.size.width, 190)];
    _iamge3 = [[UIImageView alloc] initWithFrame:CGRectMake(self.bounds.size.width * 3, 0, self.bounds.size.width, 190)];
    _image4 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, 190)];
    _image5 = [[UIImageView alloc] initWithFrame:CGRectMake(self.bounds.size.width * 4, 0, self.bounds.size.width, 190)];
    
    [_scrollView addSubview:_iamge1];
    [_scrollView addSubview:_iamge2];
    [_scrollView addSubview:_iamge3];
    [_scrollView addSubview:_image4];
    [_scrollView addSubview:_image5];
    _scrollView.showsVerticalScrollIndicator = NO;
    _scrollView.showsHorizontalScrollIndicator = NO;
    _scrollView.bounces = NO;
    _scrollView.pagingEnabled = YES;
    _scrollView.scrollsToTop = NO;
    _scrollView.autoresizesSubviews = YES;
    _scrollView.delegate = self;
    [self addSubview:_scrollView];
    
    _titleImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 192, 30, 30)];
    _titleImage.image = [UIImage imageNamed:@"night_biz_navigation_tab_news"];
    _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(45, 195, self.bounds.size.width - 110, 20)];
    [self addSubview:_titleLabel];
    [self addSubview:_titleImage];
    if ([UIScreen mainScreen].bounds.size.width == 375) {
        [self addPageControl];
    }
 
}


#pragma mark - 添加pageControl
- (void)addPageControl
{
    _pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(self.scrollView.bounds.size.width -    60, self.scrollView.bounds.size.height, 60, 30)];
    _pageControl.numberOfPages = 3;
    _pageControl.currentPage = 0;
    _scrollView.contentOffset = CGPointMake(self.scrollView.bounds.size.width * 1, 0);
    _pageControl.currentPageIndicatorTintColor = [UIColor redColor];
    _pageControl.pageIndicatorTintColor = [UIColor blackColor];
    [self addSubview:_pageControl];
    
    
}

@end
